<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>执行结果 - 小红书搜索工具</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(135deg, #ff6b6b 0%, #ffa726 100%);
            color: white;
            padding: 20px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .header h1 {
            font-size: 28px;
            font-weight: 600;
        }

        .nav-links {
            display: flex;
            gap: 15px;
        }

        .nav-links a {
            color: white;
            text-decoration: none;
            padding: 8px 16px;
            border-radius: 20px;
            background: rgba(255, 255, 255, 0.2);
            transition: all 0.3s ease;
        }

        .nav-links a:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        .nav-links a.active {
            background: rgba(255, 255, 255, 0.4);
        }

        .user-info {
            position: relative;
        }

        .user-phone {
            background: rgba(255, 255, 255, 0.2);
            padding: 8px 16px;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .user-phone:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        .dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            background: white;
            border-radius: 10px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            min-width: 120px;
            z-index: 1000;
            display: none;
        }

        .dropdown.show {
            display: block;
        }

        .dropdown-item {
            padding: 12px 16px;
            color: #333;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        .dropdown-item:hover {
            background: #f8f9fa;
        }

        .main-content {
            padding: 30px;
        }

        .toolbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 15px;
        }

        .toolbar h2 {
            color: #333;
            margin: 0;
        }

        .toolbar-actions {
            display: flex;
            gap: 15px;
        }

        .search-filters {
            background: white;
            padding: 20px;
            border-radius: 15px;
            margin-bottom: 30px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .filter-row {
            display: flex;
            gap: 15px;
            align-items: end;
            margin-bottom: 15px;
        }

        .filter-group {
            flex: 1;
        }

        .filter-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 600;
            color: #333;
        }

        .filter-group input, .filter-group select {
            width: 100%;
            padding: 8px 12px;
            border: 2px solid #e9ecef;
            border-radius: 8px;
            font-size: 14px;
            transition: border-color 0.3s ease;
        }

        .filter-group input:focus, .filter-group select:focus {
            outline: none;
            border-color: #667eea;
        }

        .btn {
            padding: 12px 24px;
            border: none;
            border-radius: 10px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            text-decoration: none;
            display: inline-block;
        }

        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }

        .btn-success {
            background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
            color: white;
        }

        .btn-success:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4);
        }

        .btn-warning {
            background: linear-gradient(135deg, #ffa726 0%, #ff7043 100%);
            color: white;
        }

        .btn-warning:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(255, 167, 38, 0.4);
        }

        .btn-small {
            padding: 6px 12px;
            font-size: 12px;
        }

        .results-section {
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .results-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .result-card {
            background: white;
            border-radius: 15px;
            padding: 20px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
            border: 1px solid #e9ecef;
        }

        .result-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        }

        .result-image {
            width: 100%;
            height: 300px;
            object-fit: contain;
            border-radius: 10px;
            margin-bottom: 15px;
            background: #f8f9fa;
            cursor: pointer;
        }

        .result-title {
            font-weight: 600;
            margin-bottom: 10px;
            color: #333;
            font-size: 16px;
            line-height: 1.4;
        }

        .result-info {
            font-size: 14px;
            color: #666;
            margin-bottom: 5px;
        }

        .result-info strong {
            color: #333;
        }

        .result-qr-link {
            display: inline-block;
            margin-top: 10px;
            padding: 6px 12px;
            background: #e9ecef;
            border-radius: 20px;
            text-decoration: none;
            color: #495057;
            font-size: 12px;
            transition: all 0.3s ease;
        }

        .result-qr-link:hover {
            background: #dee2e6;
            color: #212529;
        }

        .pagination {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 8px;
            margin-top: 30px;
            flex-wrap: wrap;
        }

        .pagination button {
            padding: 8px 12px;
            border: 1px solid #ddd;
            background: white;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 14px;
            min-width: 40px;
        }

        .pagination button:hover:not(:disabled) {
            background: #f8f9fa;
            border-color: #667eea;
        }

        .pagination button.active {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }

        .pagination button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background: #f8f9fa;
        }

        .pagination span {
            display: flex;
            align-items: center;
            font-size: 14px;
            white-space: nowrap;
        }

        .pagination input[type="number"] {
            width: 60px;
            padding: 4px 6px;
            margin: 0 5px;
            border: 1px solid #ddd;
            border-radius: 3px;
            text-align: center;
            font-size: 14px;
        }

        .pagination .jump-btn {
            padding: 4px 8px;
            margin-left: 5px;
            border: 1px solid #ddd;
            border-radius: 3px;
            background: white;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s ease;
        }

        .pagination .jump-btn:hover {
            background: #f8f9fa;
            border-color: #667eea;
        }

        .statistics {
            display: flex;
            gap: 20px;
            margin-bottom: 20px;
        }

        .stat-card {
            flex: 1;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
        }

        .stat-number {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 5px;
        }

        .stat-label {
            font-size: 14px;
            opacity: 0.9;
        }

        .hidden {
            display: none !important;
        }

        .loading {
            text-align: center;
            padding: 40px;
            color: #666;
        }

        /* 弹窗样式 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
        }

        .modal-content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            max-width: 90%;
            max-height: 90%;
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }

        .modal-title {
            font-size: 18px;
            font-weight: 600;
            color: #333;
        }

        .close {
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
            color: #999;
            line-height: 1;
        }

        .close:hover {
            color: #333;
        }

        .modal-image {
            max-width: 100%;
            max-height: 70vh;
            object-fit: contain;
            border-radius: 10px;
            display: block;
            margin: 0 auto;
        }

        .modal-info {
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }

        .modal-info p {
            margin: 5px 0;
            color: #666;
        }

        .modal-info strong {
            color: #333;
        }

        .error {
            color: #dc3545;
            background: #f8d7da;
            border: 1px solid #f5c6cb;
            padding: 10px;
            border-radius: 5px;
            margin-top: 10px;
        }

        .success {
            color: #155724;
            background: #d4edda;
            border: 1px solid #c3e6cb;
            padding: 10px;
            border-radius: 5px;
            margin-top: 10px;
        }

        @media (max-width: 768px) {
            .filter-row {
                flex-direction: column;
                gap: 15px;
            }
            
            .filter-row[style*="justify-content: flex-start"] {
                flex-direction: row;
                flex-wrap: wrap;
                gap: 10px;
                justify-content: flex-start !important;
            }
            
            .filter-row[style*="justify-content: flex-start"] .btn {
                flex: 1;
                min-width: 100px;
                margin: 0 !important;
            }
            
            .results-grid {
                grid-template-columns: 1fr;
            }
            
            .statistics {
                flex-direction: column;
            }
            
            .pagination {
                flex-direction: column;
                gap: 15px;
            }
            
            .pagination > span {
                order: -1;
                margin-left: 0;
                margin-bottom: 10px;
            }
            
            .pagination button {
                min-width: 35px;
                padding: 6px 10px;
                font-size: 12px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>小红书搜索工具 - 执行结果</h1>
            <div class="nav-links">
                <a href="index.html">首页</a>
                <a href="task.html">任务管理</a>
                <a href="result.html" class="active">执行结果</a>
            </div>
            <div class="user-info">
                <div class="user-phone" id="userPhone" onclick="toggleDropdown()">
                    未登录
                </div>
                <div class="dropdown" id="dropdown">
                    <div class="dropdown-item" onclick="logout()">退出登录</div>
                </div>
            </div>
        </div>

        <div class="main-content">
            <!-- 任务选择器 -->
            <div class="search-filters" id="taskSelector">
                <h3 style="margin-bottom: 15px; color: #333;">选择任务</h3>
                <div class="filter-row">
                    <div class="filter-group" style="width: 25%;">
                        <select id="taskNameFilter" onchange="applyFilters()" style="width: 100%;">
                            <option value="">全部任务</option>
                        </select>
                    </div>
                </div>
                <div class="filter-row" style="margin-top: 15px; justify-content: flex-start;">
                    <button class="btn btn-warning" onclick="clearFilters()">显示全部</button>
                    <button class="btn btn-success" onclick="refreshResults()" style="margin-left: 10px;">刷新结果</button>
                </div>
            </div>

            <!-- 结果列表 -->
            <div class="results-section">
                <!-- 统计信息 -->
                <div class="statistics hidden" id="statisticsSection">
                    <div class="stat-card">
                        <div class="stat-number" id="totalCount">0</div>
                        <div class="stat-label">总结果数</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-number" id="currentPageCount">0</div>
                        <div class="stat-label">当前页数量</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-number" id="totalPagesCount">0</div>
                        <div class="stat-label">总页数</div>
                    </div>
                </div>
                
                <div class="results-grid" id="resultsGrid">
                    <!-- 结果将在这里显示 -->
                </div>
                
                <!-- 分页 -->
                <div class="pagination" id="pagination">
                    <!-- 分页按钮将在这里显示 -->
                </div>
            </div>
        </div>
    </div>

    <!-- 二维码查看弹窗 -->
    <div id="qrModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <div class="modal-title">二维码</div>
                <span class="close" onclick="closeQrModal()">&times;</span>
            </div>
            <img id="modalImage" class="modal-image" src="" alt="二维码">
        </div>
    </div>

    <script>
        let currentPage = 1;
        let pageSize = 12;
        let totalPages = 1;
        let currentTaskId = null;
        let currentFilters = {};
        
        // 页面加载时检查登录状态
        window.onload = function() {
            parseUrlParams(); // 先解析URL参数
            checkLoginStatus();
            loadTaskNames();
        };

        // 解析URL参数
        function parseUrlParams() {
            const urlParams = new URLSearchParams(window.location.search);
            const taskId = urlParams.get('taskId');
            
            if (taskId) {
                currentTaskId = taskId;
                // 注意：这里不设置pageTitle，因为页面没有这个元素
                console.log('从URL获取到taskId:', taskId);
            }
        }

        // 加载任务列表
        async function loadTaskNames() {
            const phoneNumber = localStorage.getItem('phoneNumber');
            
            if (!phoneNumber) {
                return;
            }

            try {
                const response = await fetch('/xhs/api/task/simple-list', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        phoneNumber: phoneNumber
                    })
                });

                const data = await response.json();
                
                if (data.code === 200) {
                    const taskSelect = document.getElementById('taskNameFilter');
                    taskSelect.innerHTML = '<option value="">全部任务</option>';
                    
                    data.data.forEach(task => {
                        const option = document.createElement('option');
                        option.value = task.taskId;  // 使用任务ID作为值
                        option.textContent = task.taskName;  // 显示任务名称
                        // 如果URL中有taskId参数，自动选中对应任务
                        if (currentTaskId && task.taskId == currentTaskId) {
                            option.selected = true;
                        }
                        taskSelect.appendChild(option);
                    });
                    
                    // 如果URL中有taskId参数，加载对应任务的结果
                    if (currentTaskId) {
                        loadResults();
                    }
                } else {
                    console.error('获取任务列表失败:', data.message);
                }
            } catch (error) {
                console.error('获取任务列表失败:', error);
            }
        }

        // 检查登录状态
        function checkLoginStatus() {
            const phoneNumber = localStorage.getItem('phoneNumber');
            if (phoneNumber) {
                document.getElementById('userPhone').textContent = phoneNumber;
                loadResults();
            } else {
                alert('请先登录');
                window.location.href = 'index.html';
            }
        }

        // 切换下拉菜单
        function toggleDropdown() {
            const dropdown = document.getElementById('dropdown');
            dropdown.classList.toggle('show');
        }

        // 退出登录
        function logout() {
            localStorage.removeItem('phoneNumber');
            window.location.href = 'index.html';
        }

        // 点击其他地方关闭下拉菜单（已移到页面底部统一处理）



        // 加载结果列表
        async function loadResults() {
            const phoneNumber = localStorage.getItem('phoneNumber');
            
            if (!phoneNumber) {
                return;
            }

            try {
                let url;
                let requestBody;
                
                if (currentTaskId) {
                    // 加载指定任务的结果
                    url = '/xhs/api/result/task/page';
                    requestBody = {
                        phoneNumber: phoneNumber,
                        taskId: currentTaskId,
                        pageNum: currentPage,
                        pageSize: pageSize
                    };
                } else {
                    // 加载所有结果
                    url = '/xhs/api/result/page';
                    requestBody = {
                        phoneNumber: phoneNumber,
                        pageNum: currentPage,
                        pageSize: pageSize
                    };
                }

                const response = await fetch(url, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify(requestBody)
                });

                const data = await response.json();
                
                if (data.code === 200) {
                    displayResults(data.data.records);
                    totalPages = data.data.pages;
                    updatePagination();
                    updateStatistics(data.data);
                } else {
                    console.error('获取结果列表失败:', data.message);
                }
            } catch (error) {
                console.error('获取结果列表失败:', error);
            }
        }

        // 显示结果列表
        function displayResults(results) {
            const resultsGrid = document.getElementById('resultsGrid');
            
            if (!results || results.length === 0) {
                resultsGrid.innerHTML = '<div class="loading">暂无结果</div>';
                return;
            }

            resultsGrid.innerHTML = '';
            
            results.forEach(result => {
                const card = document.createElement('div');
                card.className = 'result-card';
                
                // 检查imageUrl是否存在
                let imageHtml = '';
                if (result.imageUrl && result.imageUrl.trim() !== '') {
                    // 使用图片代理接口来避免防盗链问题
                    const proxyImageUrl = `/xhs/api/image/proxy?url=${encodeURIComponent(result.imageUrl)}`;
                    imageHtml = `<img src="${proxyImageUrl}" alt="图片" class="result-image" 
                         onclick="showQrModal('${result.imageUrl}')"
                         onerror="this.src=''">`;
                } else {
                    imageHtml = `<div class="result-image" style="display: flex; align-items: center; justify-content: center; background: #f8f9fa; color: #666;">暂无图片</div>`;
                }
                
                card.innerHTML = `
                    ${imageHtml}
                    <div class="result-title">${result.noteTitle || '无标题'}</div>
                    <div class="result-info"><strong>任务名称:</strong> ${result.taskName || '无'}</div>

                    <div class="result-info"><strong>关键词:</strong> ${result.keyword || '无'}</div>
                    <div class="result-info"><strong>笔记ID:</strong> ${result.noteId || '无'}</div>
                    <div class="result-info"><strong>帖子创建时间:</strong> ${result.postCreateTime || '未知'}</div>
                    <div class="result-info"><strong>扫描时间:</strong> ${result.scanTimeFormatted || formatDate(result.scanTime)}</div>

                `;
                resultsGrid.appendChild(card);
            });
        }

        // 更新统计信息
        function updateStatistics(pageData) {
            const statisticsSection = document.getElementById('statisticsSection');
            const totalCount = document.getElementById('totalCount');
            const currentPageCount = document.getElementById('currentPageCount');
            const totalPagesCount = document.getElementById('totalPagesCount');
            
            if (pageData && pageData.total > 0) {
                totalCount.textContent = pageData.total || 0;
                currentPageCount.textContent = pageData.records ? pageData.records.length : 0;
                totalPagesCount.textContent = pageData.pages || 0;
                statisticsSection.classList.remove('hidden');
            } else {
                statisticsSection.classList.add('hidden');
            }
        }

        // 更新分页
        function updatePagination() {
            const pagination = document.getElementById('pagination');
            
            if (totalPages <= 1) {
                pagination.innerHTML = '';
                return;
            }

            let paginationHTML = '';
            
            // 首页
            paginationHTML += `<button ${currentPage === 1 ? 'disabled' : ''} onclick="changePage(1)">首页</button>`;
            
            // 上一页
            paginationHTML += `<button ${currentPage === 1 ? 'disabled' : ''} onclick="changePage(${currentPage - 1})">上一页</button>`;
            
            // 页码逻辑：智能显示页码
            const pageNumbers = generatePageNumbers(currentPage, totalPages);
            pageNumbers.forEach(pageNum => {
                if (pageNum === '...') {
                    paginationHTML += `<span style="padding: 8px 12px; color: #999;">...</span>`;
                } else {
                    if (pageNum === currentPage) {
                        paginationHTML += `<button class="active">${pageNum}</button>`;
                    } else {
                        paginationHTML += `<button onclick="changePage(${pageNum})">${pageNum}</button>`;
                    }
                }
            });
            
            // 下一页
            paginationHTML += `<button ${currentPage === totalPages ? 'disabled' : ''} onclick="changePage(${currentPage + 1})">下一页</button>`;
            
            // 尾页
            paginationHTML += `<button ${currentPage === totalPages ? 'disabled' : ''} onclick="changePage(${totalPages})">尾页</button>`;
            
            // 页码跳转
            paginationHTML += `
                <span style="margin-left: 20px; color: #666;">
                    跳转到 
                    <input type="number" id="pageInput" min="1" max="${totalPages}" value="${currentPage}">
                    页
                    <button onclick="jumpToPage()" class="jump-btn">跳转</button>
                </span>
            `;
            
            // 显示总页数和当前页
            paginationHTML += `<span style="margin-left: 20px; color: #666;">第 ${currentPage} 页，共 ${totalPages} 页</span>`;
            
            pagination.innerHTML = paginationHTML;
            
            // 设置页码输入框事件
            setupPageInputEvents();
        }

        // 生成智能页码数组
        function generatePageNumbers(current, total) {
            const pages = [];
            const showPages = 5; // 显示的页码数量
            
            if (total <= showPages + 2) {
                // 总页数较少，显示所有页码
                for (let i = 1; i <= total; i++) {
                    pages.push(i);
                }
            } else {
                // 总页数较多，智能显示
                if (current <= 3) {
                    // 当前页在前面
                    for (let i = 1; i <= showPages; i++) {
                        pages.push(i);
                    }
                    pages.push('...');
                    pages.push(total);
                } else if (current >= total - 2) {
                    // 当前页在后面
                    pages.push(1);
                    pages.push('...');
                    for (let i = total - showPages + 1; i <= total; i++) {
                        pages.push(i);
                    }
                } else {
                    // 当前页在中间
                    pages.push(1);
                    pages.push('...');
                    
                    const start = Math.max(2, current - 1);
                    const end = Math.min(total - 1, current + 1);
                    
                    for (let i = start; i <= end; i++) {
                        pages.push(i);
                    }
                    
                    pages.push('...');
                    pages.push(total);
                }
            }
            
            return pages;
        }

        // 跳转到指定页
        function jumpToPage() {
            const pageInput = document.getElementById('pageInput');
            const page = parseInt(pageInput.value);
            
            if (isNaN(page) || page < 1 || page > totalPages) {
                alert(`请输入1到${totalPages}之间的页码`);
                pageInput.value = currentPage;
                return;
            }
            
            if (page !== currentPage) {
                changePage(page);
            }
        }

        // 添加键盘事件支持
        function setupPageInputEvents() {
            // 延迟执行，确保DOM已更新
            setTimeout(() => {
                const pageInput = document.getElementById('pageInput');
                if (pageInput) {
                    pageInput.addEventListener('keypress', function(e) {
                        if (e.key === 'Enter') {
                            jumpToPage();
                        }
                    });
                    
                    pageInput.addEventListener('blur', function() {
                        const page = parseInt(this.value);
                        if (isNaN(page) || page < 1 || page > totalPages) {
                            this.value = currentPage;
                        }
                    });
                }
            }, 100);
        }

        // 切换页码
        function changePage(page) {
            if (page < 1 || page > totalPages || page === currentPage) {
                return;
            }
            
            currentPage = page;
            loadResults();
        }

        // 刷新结果
        function refreshResults() {
            currentPage = 1;
            loadResults();
        }

        // 应用筛选
        async function applyFilters() {
            const taskId = document.getElementById('taskNameFilter').value;
            
            currentTaskId = taskId || null;
            
            // 重新加载结果
            currentPage = 1;
            loadResults();
        }

        // 清空筛选
        function clearFilters() {
            document.getElementById('taskNameFilter').value = '';
            
            currentTaskId = null;
            currentPage = 1;
            loadResults();
        }

        // 格式化日期
        function formatDate(dateString) {
            if (!dateString) return '无';
            const date = new Date(dateString);
            return date.toLocaleString('zh-CN');
        }

        // 显示二维码弹窗
        function showQrModal(imageUrl) {
            // 检查imageUrl是否存在
            if (imageUrl && imageUrl.trim() !== '') {
                // 使用图片代理接口来避免防盗链问题
                const proxyImageUrl = `/xhs/api/image/proxy?url=${encodeURIComponent(imageUrl)}`;
                document.getElementById('modalImage').src = proxyImageUrl;
                document.getElementById('modalImage').style.display = 'block';
            } else {
                document.getElementById('modalImage').style.display = 'none';
            }
            
            document.getElementById('qrModal').style.display = 'block';
        }

        // 关闭二维码弹窗
        function closeQrModal() {
            document.getElementById('qrModal').style.display = 'none';
        }

        // 点击弹窗外部关闭
        window.addEventListener('click', function(event) {
            const modal = document.getElementById('qrModal');
            if (event.target === modal) {
                closeQrModal();
            }
            
            // 处理用户下拉菜单
            if (!event.target.matches('.user-phone')) {
                const dropdown = document.getElementById('dropdown');
                if (dropdown && dropdown.classList.contains('show')) {
                    dropdown.classList.remove('show');
                }
            }
        });
    </script>
</body>
</html> 